/**
 * 必填校验
 */
interface RequiredParams {
  type?: string
  message?: string
}
// 固化字面量
const typeMessage = {
  change: '请选择',
  upload: '请上传',
} as const
export function required(params?: RequiredParams) {
  // 三元运算
  let message: string = params?.type ? typeMessage[params?.type as keyof typeof typeMessage] : '请输入' // keyof typeof typeMessage -> change| upload
  // 拼接message
  message = `${message}${params?.message || ''}`
  return { required: true, message, trigger: ['blur', 'change'] }
}
